package Function;

public class Function {
	
	public static void get_ShowMatrix(String str ,double[] Array){
		int row = Array.length;
		
		System.out.println("\n" + str + " = ");
		
		for(int i = 0 ; i < row ; i++){
			System.out.printf("%f\t" , Array[i]);
		}
		
		System.out.println();
	}
	
	public static void get_ShowMatrix(String str , double[][] Array){
		int col = Array.length;
		int row = Array[0].length;
		
		System.out.println("\n" + str + " = ");
		
		for(int i = 0 ; i < col ; i++){
			for(int j = 0 ; j < row ; j++){
				System.out.printf("%f\t" , Array[i][j]);
			}
			System.out.println();
		}
		System.out.println();
		
	}

	public static double[][] get_input(double[][] data , int input_size){
		int col = data.length;
		int row = input_size;
		double[][] result = new double[col][row];
		
		for(int i = 0 ; i < col ; i++){
			for(int j = 0 ; j < row ; j++){
				result[i][j] = data[i][j];
			}
		}
		
		return result;
	}

	public static double[][] get_output(double[][] data , int output_size){
		int col = data.length;
		int row = output_size;
		int trow = data[0].length;
		
		double[][] result = new double[col][row];
		
		for(int i = 0 ; i < col ; i++){
			for(int j = 0 ; j < row ; j++){
				result[i][j] = data[i][trow-row+j];
			}
		}
		
		return result;
	}

	public static double[][] get_train(double[][] data ){	
		int col = data.length;
		int row = data[0].length;
		
		double[][] result = new double[col/2][row];
		int rcol = 0;
		
		for(int i = 0 ; i < col ; i++){
			
			if( (i % 2) == 0){
				result[rcol] = data[i];
				rcol++;
			}
		}
	
		return result;
	}
	
	public static double[][] get_test(double[][] data){
		int col = data.length;
		int row = data[0].length;
		
		double[][] result = new double[col/2][row];
		int rcol = 0;
		
		for(int i = 0 ; i < col ; i++){
			if( (i % 2) != 0){
				result[rcol] = data[i];
				rcol++;
			}
		}
		
		return result;
	}
	
	public static double get_sig(double net){
		double result = 2/(1 + Math.exp(-net)) -1;
		return result;
	}
	
	public static double get_sigp(double net){
		double result = 0.5*(1+get_sig(net)) * (1-get_sig(net));
		return result;
	}
	
	public static double[][] rowPlus(double[][] data, int _row){
		int col = data.length;
		int row = data[0].length+_row;
		
		double[][] result = new double[col][row];
		
		for(int i = 0 ; i < col ; i++){
			for(int j = 0 ; j <row-_row ;j++){
				result[i][j] = data[i][j];
			}
		}
		return result;
		
	}

}
